<?php
/**
 * Create by 11li
 * Date 2020/3/30
 * Time 23:44
 *
 */

namespace app\common\service\v2;


use app\common\model\AgentStock;

class StockService
{
	
	/**
	 * 获取代理某个商品的库存数量
	 * @param $agentId
	 * @param $goodsId
	 * @param int $specId
	 * @return int
	 * @throws \think\exception\DbException
	 */
	public static function getAgentGoodsIdStock($agentId, $goodsId, $specId= 0)
	{
		$row = AgentStock::get(['agent_shop_id' => $agentId, 'goods_id' => $goodsId, 'spec_id' => $specId]);
		return $row ? $row['number'] : 0;
	}
}